package com.ruoyi.web.controller.stock;

import com.ruoyi.common.annotation.Log;
import com.ruoyi.common.core.controller.BaseController;
import com.ruoyi.common.core.domain.AjaxResult;
import com.ruoyi.common.core.page.TableDataInfo;
import com.ruoyi.common.enums.BusinessType;
import com.ruoyi.stock.domain.TransactionDiscipline;
import com.ruoyi.stock.service.ITransactionDisciplineService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import java.util.List;

/**
 * 交易纪律Controller
 * @author ruoyi
 * @date 2025-05-13
 */
@RestController
@RequestMapping("/stock/discipline")
public class TransactionDisciplineController extends BaseController {
    @Autowired
    private ITransactionDisciplineService transactionDisciplineService;

    /**
     * 查询交易纪律列表
     */
    @GetMapping("/list")
    public TableDataInfo list(TransactionDiscipline transactionDiscipline) {
        startPage();
        List<TransactionDiscipline> list = transactionDisciplineService.selectTransactionDisciplineList(transactionDiscipline);
        return getDataTable(list);
    }


    /**
     * 获取交易纪律详细信息
     */
    @GetMapping(value = "/{id}")
    public AjaxResult getInfo(@PathVariable("id") Long id) {
        return success(transactionDisciplineService.selectTransactionDisciplineById(id));
    }

    /**
     * 新增交易纪律
     */
    @Log(title = "交易纪律", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody TransactionDiscipline transactionDiscipline) {
        return toAjax(transactionDisciplineService.insertTransactionDiscipline(transactionDiscipline));
    }

    /**
     * 修改交易纪律
     */
    @Log(title = "交易纪律", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody TransactionDiscipline transactionDiscipline) {
        return toAjax(transactionDisciplineService.updateTransactionDiscipline(transactionDiscipline));
    }

    /**
     * 删除交易纪律
     */
    @Log(title = "交易纪律", businessType = BusinessType.DELETE)
    @DeleteMapping("/{ids}")
    public AjaxResult remove(@PathVariable Long[] ids) {
        return toAjax(transactionDisciplineService.deleteTransactionDisciplineByIds(ids));
    }
}
